//
//  yinDaoYeViewController.m
//  yiyou
//
//  Created by tangtangchitangtang on 2017/9/25.
//  Copyright © 2017年 tangtangchitangtang. All rights reserved.
//

#import "yinDaoYeViewController.h"
#import "HomeViewController.h"
#import "informationViewController.h"
#import "CaseViewController.h"
#import "MyViewController.h"
#import "SuccessCaseViewController.h"

@interface yinDaoYeViewController ()<UIScrollViewDelegate>

@property (nonatomic,strong) UIScrollView *scrollView2;

@end

@implementation yinDaoYeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self wr_setNavBarBackgroundAlpha:0];
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
 
    [self Qidong];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    
}

-(void)Qidong{
    
    _scrollView2=[UIScrollView new];
    [self.view addSubview:_scrollView2];
    [_scrollView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.left.right.mas_equalTo(0);
    }];
    //必须设置
    _scrollView2.contentSize=CGSizeMake(_mainW*4,0);
    _scrollView2.showsHorizontalScrollIndicator=NO;
    _scrollView2.contentOffset=CGPointMake(0,0);
    _scrollView2.pagingEnabled=YES;
    _scrollView2.delegate=self;
    
    
    for(int i=0;i<3;i++){
        UIImageView *imgView=[UIImageView new];
        [_scrollView2 addSubview:imgView];
        [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.width.mas_equalTo(_mainW);
            make.height.mas_equalTo(_mainH);
            make.left.mas_equalTo(i*_mainW);
        }];
        NSString *imgUrl=[NSString stringWithFormat:@"启动页-%d",i+1];
        imgView.image=[UIImage imageNamed:imgUrl];
        if (i==2) {
            imgView.userInteractionEnabled=YES;
            UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jingRu)];
            [imgView addGestureRecognizer:tapGesture];
            
        }
    }
    
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGPoint points=scrollView.contentOffset;
    
    int page=points.x/_mainW;
    if (page==3) {
        [self jingRu];
    }
    
    
    
}

-(void)jingRu{
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    
    NSString *getAPPBanben=[ZQTools getAPPBanben];
    [user setObject:getAPPBanben forKey:@"getAPPBanben"];
    
    HomeViewController *shouye=[[HomeViewController alloc] init];
    informationViewController *huDong=[[informationViewController alloc] init];
    CaseViewController *caseView=[[CaseViewController alloc] init];
    MyViewController *youJi=[[MyViewController alloc] init];
    SuccessCaseViewController *SuccessCase=[[SuccessCaseViewController alloc] init];
    
    UINavigationController *nav1= [[UINavigationController alloc] initWithRootViewController:shouye];
    UINavigationController *nav2= [[UINavigationController alloc] initWithRootViewController:huDong];
    UINavigationController *nav3= [[UINavigationController alloc] initWithRootViewController:SuccessCase];
    UINavigationController *nav4= [[UINavigationController alloc] initWithRootViewController:caseView];
    UINavigationController *nav5= [[UINavigationController alloc] initWithRootViewController:youJi];
    
    
    nav1.title=@"首页";
    nav2.title=@"资讯";
    nav3.title=@"案例";
    nav4.title=@"案件";
    nav5.title=@"我的";
    
    [nav1.tabBarItem setSelectedImage:[UIImage imageNamed:@"首页1"]];
    [nav1.tabBarItem setImage:[UIImage imageNamed:@"首页"]];
    
    [nav2.tabBarItem setSelectedImage:[UIImage imageNamed:@"资讯1"]];
    [nav2.tabBarItem setImage:[UIImage imageNamed:@"资讯"]];
    
    [nav3.tabBarItem setSelectedImage:[UIImage imageNamed:@"经典案例2"]];
    [nav3.tabBarItem setImage:[UIImage imageNamed:@"经典案例1"]];
    
    
    [nav4.tabBarItem setSelectedImage:[UIImage imageNamed:@"案件1"]];
    [nav4.tabBarItem setImage:[UIImage imageNamed:@"案件"]];
    
    [nav5.tabBarItem setSelectedImage:[UIImage imageNamed:@"我的1"]];
    [nav5.tabBarItem setImage:[UIImage imageNamed:@"我的"]];
    
    [[UITabBar appearance] setTintColor:_backgroundColor];
    
    UITabBarController *bar=[[UITabBarController alloc] init];
    bar.viewControllers=@[nav1,nav2,nav3,nav4,nav5];
    
    self.view.window.rootViewController=bar;
    [self.view.window makeKeyAndVisible];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
